package dissertation.services.ejbfield;

import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiModifierList;

public class EJBFieldService implements IEJBFieldService {
    @Override
    public void annotateEJBField(PsiField psiField, String annotationString) {
        PsiModifierList modifierList = psiField.getModifierList();
        if (modifierList != null) {
            modifierList.addAnnotation(annotationString);
        }
    }

    @Override
    public PsiField createFieldFromText(Project project, String fieldString) {
        PsiElementFactory psiElementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
        return psiElementFactory.createFieldFromText(fieldString, null);
    }
}
